home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- #include "gl.h"
- #include "device.h"
- #include "geom.h"
- #include "class.h"
- #include "classIds.h"
- #include "selectors.h"
- #include "mbox.h"
- #include "individual.h"
- #include "behavior.h"
- #include "doers.h"
- #include "colors.h"
-
- #include "pebbles.h"
-
- extern model *stones[];
- extern pebbles pebbleTemplate;
- extern float sin(), cos();
-
- #define PI 3.14159265358979323844
- #define DEG(x) ((float)x*(float)180/PI)
- #define RAD(x) ((float)x*PI/(float)180)
-
-
- /* ARGSUSED */
- floorinit(s, argtype, univol)
- register pebbles *s;
- int argtype;
- point *univol;
- {
- register model **stone = stones, *m = s->me.descr;
- long *v;
- point *pnts, *p;
- int i, num, alpha;
- register j, r;
- float circumf, chord;
-
- s->floor.x = univol->x >> 1;
- s->floor.y = univol->y >> 1;
- s->floor.z = 0;
- chord = 1200.0;
- for(i = 0; i<STONES && m; i++, stone++, m = m->next, chord -= 80.0) {
- /* make a prototype pebble */
- makeobj((Object)stone);
- pushmatrix();
- scale(m->scale.x,m->scale.y,m->scale.z); /* */
- fishColor(m->color);
- /* setpattern(NO_TEXTURE); /* */
- v = m->vertices;
- pnts = m->points;
- while(*v) {
- p = &pnts[*(v++)];
- pmvi(p->x, p->y, p->z);
- while(*v) {
- p = &pnts[*(v++)];
- pdri(p->x, p->y, p->z);
- }
- pclos();
- v++;
- }
- if (m->texture) {
- fishColor(TEX_COLOR);
- setpattern(m->texture);
- v = m->vertices;
- pnts = m->points;
- while(*v) {
- p = &pnts[*(v++)];
- pmvi(p->x, p->y, p->z);
- while(*v) {
- p = &pnts[*(v++)];
- pdri(p->x, p->y, p->z);
- }
- pclos();
- v++;
- }
- setpattern(NO_TEXTURE);
- fishColor(m->color);
- }
- /* */
- popmatrix();
- closeobj();
-
- /* make the real pebbles */
- makeobj((Object)m);
- pushLongName(s);
- backface(FALSE);
- fishWritemask(BACKGROUND);
- fishColor(m->color);
- pushmatrix();
- #define WIMP
- #ifdef WIMP
- rotate(900,'y');
- #endif /* WIMP */
- /* scale(3.0,3.0,1.5); /* */
- translate((Coord)m->translate.x,
- (Coord)m->translate.y,
- (Coord)m->translate.z);
- callobj((Object)stone);
- for(r = 700; r < s->floor.x; r += 700) {
- circumf = 2.0 * PI * (float)r;
- num = (int)(circumf / chord);
- alpha = (3600 / num);
- rotate(-300, 'z');
- for(j = 0; j < num; j++) {
- rotate(alpha, 'z');
- pushmatrix();
- translate((Coord)r, 0.0, 0.0);
- callobj((Object)stone);
- popmatrix();
- }
- }
- popmatrix();
- backface(TRUE);
- popLongName();
- closeobj();
- m->compiled = TRUE;
- m->component = (Object)m;
- }
- }
-